fn main() {
    println!("-----------------------");
    test01_create();
    println!("-----------------------");
    test02_update();
    println!("-----------------------");
    test03_select();
    println!("-----------------------");
    test04_traversal();
    println!("-----------------------");
    test05_enum();
    println!("-----------------------");
}
fn test01_create() {
    let v: Vec<i32> = Vec::new();
    println!("{v:?}");
    let v = vec![1, 2, 3];
    println!("{v:?}");
}
fn test02_update() {
    let mut v = Vec::new();
    v.push(1);
    v.push(2);
    v.push(3);

    println!("{v:?}");
}
fn test03_select() {
    let v = vec![1, 2, 3, 4, 5];
    let third: &i32 = &v[2];
    println!("The third element is {third}");

    let third: Option<&i32> = v.get(2);
    match third {
        Some(third) => println!("The third element is {third}"),
        None => println!("There is no third element."),
    }

    let v = vec![1, 2, 3, 4, 5];

    //let does_not_exist = &v[100];//panic
    //let does_not_exist = v.get(100);//ok

    let mut v = vec![1, 2, 3, 4, 5];

    let first = &v[0];

    //v.push(6);//err

    println!("The first element is: {first}");
}
fn test04_traversal() {
    let v = vec![100, 32, 57];
    for i in &v {
        println!("{i}");
    }

    let mut v = vec![100, 32, 57];
    for i in &mut v {
        *i += 50;
    }
}
fn test05_enum() {
    let row = vec![
        SpreadsheetCell::Int(3),
        SpreadsheetCell::Text(String::from("blue")),
        SpreadsheetCell::Float(10.12),
    ];
    println!("{row:?}");
}
#[derive(Debug)]
enum SpreadsheetCell {
    Int(i32),
    Float(f64),
    Text(String),
}
